package com.neusoft.bizcore.activiti.listener;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

/**
 * 分发确认节点 创建时监听类 主要用于设置每个任务的委派人assignee
 */
public class DispatchConfirmNodeCreateListener implements TaskListener {

    private static final long serialVersionUID = -5073974442089091169L;

    @Override
    public void notify(final DelegateTask delegateTask) {
        final ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
        final TaskService taskService = engine.getTaskService();
        final String dispatchUser = (String) delegateTask.getVariable("dispatchUser");
        //        delegateTask.setAssignee(dispatchUser);
        taskService.claim(delegateTask.getId(), dispatchUser);
    }

}
